# RUN: ld64.lld.darwinold -arch x86_64 %s -o %t -e _main %p/Inputs/x86_64/libSystem.yaml
# RUN: llvm-objdump --unwind-info %t | FileCheck %s

# CHECK: Contents of __unwind_info section:
# CHECK:   Version:                                   0x1
# CHECK:   Common encodings array section offset:     0x1c
# CHECK:   Number of common encodings in array:       0x0
# CHECK:   Personality function array section offset: 0x1c
# CHECK:   Number of personality functions in array:  0x1
# CHECK:   Index array section offset:                0x20
# CHECK:   Number of indices in array:                0x2
# CHECK:   Common encodings: (count = 0)
# CHECK:   Personality functions: (count = 1)
# CHECK:     personality[1]: 0x00001000
# CHECK:   Top level indices: (count = 2)
# CHECK:     [0]: function offset=0x00000efb, 2nd level page offset=0x00000040, LSDA offset=0x00000038
# CHECK:     [1]: function offset=0x00000f00, 2nd level page offset=0x00000000, LSDA offset=0x00000040
# CHECK:   LSDA descriptors:
# CHECK:     [0]: function offset=0x00000efb, LSDA offset=0x00000f00
# CHECK:   Second level indices:
# CHECK:     Second level index[0]: offset in section=0x00000040, base function offset=0x00000efb
# CHECK:       [0]: function offset=0x00000efb, encoding=0x51000000
# CHECK:       [1]: function offset=0x00000efc, encoding=0x01000000
# CHECK:       [2]: function offset=0x00000efd, encoding=0x04000018
# CHECK:       [3]: function offset=0x00000efe, encoding=0x04000040
# CHECK:       [4]: function offset=0x00000eff, encoding=0x00000000
# CHECK-NOT: Contents of __compact_unwind section

--- !native
path:            '<linker-internal>'
defined-atoms:
  - name:            GCC_except_table1
    type:            unwind-lsda
    content:         [ FF, 9B, A2, 80, 80, 00, 03, 1A, 08, 00, 00, 00,
                       05, 00, 00, 00, 1A, 00, 00, 00, 01, 0D, 00, 00,
                       00, 64, 00, 00, 00, 00, 00, 00, 00, 00, 01, 00,
                       04, 00, 00, 00 ]
  - type:            compact-unwind
    content:         [ 40, 00, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00,
                       00, 00, 00, 41, 00, 00, 00, 00, 00, 00, 00, 00,
                       E0, 00, 00, 00, 00, 00, 00, 00 ]
    references:
      - kind:            pointer64Anon
        offset:          0
        target:          __Z3barv
      - kind:            pointer64
        offset:          16
        target:          ___gxx_personality_v0
      - kind:            pointer64Anon
        offset:          24
        target:          GCC_except_table1
  - type:            compact-unwind
    content:         [ C0, 00, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00,
                       00, 00, 00, 01, 00, 00, 00, 00, 00, 00, 00, 00,
                       00, 00, 00, 00, 00, 00, 00, 00 ]
    references:
      - kind:            pointer64Anon
        offset:          0
        target:          _main
  - type:            compact-unwind
    content:         [ C1, 00, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00,
                       00, 00, 00, 04, 00, 00, 00, 00, 00, 00, 00, 00,
                       00, 00, 00, 00, 00, 00, 00, 00 ]
    references:
      - kind:            pointer64Anon
        offset:          0
        target:          _needsDwarfButNoCompactUnwind

# Generic x86_64 CIE:
  - name:            LCIE
    type:            unwind-cfi
    content:         [ 14, 00, 00, 00, 00, 00, 00, 00, 01, 7A, 52, 00,
                       01, 78, 10, 01, 10, 0C, 07, 08, 90, 01, 00, 00 ]

  - type:            unwind-cfi
    content:         [ 24, 00, 00, 00, 1C, 00, 00, 00, C8, FE, FF, FF,
                       FF, FF, FF, FF, 01, 00, 00, 00, 00, 00, 00, 00,
                       00, 41, 0E, 10, 86, 02, 43, 0D, 06, 00, 00, 00,
                       00, 00, 00, 00 ]
    references:
      - kind:            unwindFDEToFunction
        offset:          8
        target:          _needsDwarfButNoCompactUnwind
      - kind:            negDelta32
        offset:          4
        target:          LCIE

  - type:            unwind-cfi
    content:         [ 24, 00, 00, 00, 44, 00, 00, 00, C8, FE, FF, FF,
                       FF, FF, FF, FF, 01, 00, 00, 00, 00, 00, 00, 00,
                       00, 41, 0E, 10, 86, 02, 43, 0D, 06, 00, 00, 00,
                       00, 00, 00, 00 ]
    references:
      - kind:            unwindFDEToFunction
        offset:          8
        target:          _needsDwarfSaysCompactUnwind
      - kind:            negDelta32
        offset:          4
        target:          LCIE

  - type:            unwind-cfi
    content:         [ 24, 00, 00, 00, 6C, 00, 00, 00, C8, FE, FF, FF,
                       FF, FF, FF, FF, 01, 00, 00, 00, 00, 00, 00, 00,
                       00, 41, 0E, 10, 86, 02, 43, 0D, 06, 00, 00, 00,
                       00, 00, 00, 00 ]
    references:
      - kind:            unwindFDEToFunction
        offset:          8
        target:          _main
      - kind:            negDelta32
        offset:          4
        target:          LCIE

  - name:            __Z3barv
    scope:           global
    content:         [ C3 ]
  - name:            _main
    scope:           global
    content:         [ C3 ]
  - name:            _needsDwarfButNoCompactUnwind
    scope:           global
    content:         [ C3 ]
  - name:            _needsDwarfSaysCompactUnwind
    scope:           global
    content:         [ C3 ]
  - name:            _noUnwindData
    scope:           global
    content:         [ C3 ]

shared-library-atoms:
  - name:            ___gxx_personality_v0
    load-name:       '/usr/lib/libc++abi.dylib'
    type:            unknown
